package org.example.AI;

/**
 * @author: 默苍璃
 * @date: 2024-07-18 10:48
 */
public class Client {
    public static void main(String[] args) {
        // 构建解释器表达式：1 + 2 - 3 * 4 / 2
        Expression expression = new SubtractExpression(
                new AddExpression(
                        new NumberExpression(1),
                        new NumberExpression(2)
                ),
                new DivideExpression(
                        new MultiplyExpression(
                                new NumberExpression(3),
                                new NumberExpression(4)
                        ),
                        new NumberExpression(2)
                )
        );

        // 创建上下文（可选）
        Context context = new Context();

        // 解释并计算表达式的值
        int result = expression.interpret(context);
        System.out.println("解释器模式计算结果：" + result);
    }
}
